import { createRouter, createWebHistory } from 'vue-router'
import One from '../views/One.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: One
    },
    {
      path: '/1',
      name: 'One',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/One.vue')
    },
    {
      path: '/2',
      name: 'Two',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/Two.vue')
    },
    {
      path: '/3',
      name: 'Three',
      component: () => import('../views/Three.vue')
    },
    {
      path: '/41',
      name: 'Four',
      component: () => import('../views/Four.vue')
    },
    {
      path: '/42',
      name: 'Four_2',
      component: () => import('../views/FourList/Four_2.vue')
    },
    {
      path: '/43',
      name: 'Four_3',
      component: () => import('../views/FourList/Four_3.vue')
    },
    {
      path: '/44',
      name: 'Four_4',
      component: () => import('../views/FourList/Four_4.vue')
    },
    // {
    //   path: '/4.5',
    //   name: 'Four_5',
    //   component: () => import('../views/FourList/Four_5.vue')
    // },
    // {
    //   path: '/4.6',
    //   name: 'Four_6',
    //   component: () => import('../views/FourList/Four_6.vue')
    // },
    {
      path: '/5',
      name: 'Five_5',
      component: () => import('../views/Five.vue')
    },
    {
      path: '/6',
      name: 'Six',
      component: () => import('../views/Six.vue')
    },
    {
      path: '/7',
      name: 'Seven',
      component: () => import('../views/Seven.vue')
    },
    {
      path: '/8',
      name: 'Eight',
      component: () => import('../views/Eight.vue')
    },
    {
      path: '/9',
      name: 'Nine',
      component: () => import('../views/Nine.vue')
    },
    {
      path: '/10',
      name: 'Ten',
      component: () => import('../views/Ten.vue')
    },
    {
      path: '/11',
      name: 'Eleven',
      component: () => import('../views/Eleven.vue')
    },
    {
      path: '/12',
      name: 'Twelve',
      component: () => import('../views/Twelve.vue')
    },
    {
      path: '/13',
      name: 'Thirteenth',
      component: () => import('../views/Thirteenth.vue')
    },
    {
      path: '/14',
      name: 'Fourteenth',
      component: () => import('../views/Fourteenth.vue')
    },
    {
      path: '/15',
      name: 'Fifteen',
      component: () => import('../views/Fifteen.vue')
    }
  ]
})
// 在路由改变后保存当前路由到 localStorage
router.afterEach((to: any) => {
  if (to.path !== '/') { // 如果不是首页，可以考虑都保存
    localStorage.setItem('lastVisitedRoute', JSON.stringify(to));
  }
});


export default router
